﻿@page "/auth"
@attribute [Authorize]

<button class="btn btn-warning" @onclick="Login">认证</button>


<br />


@if (user is not null)
{
    @user?.User?.Identity?.Name

    @foreach (var item in user.User.Claims)
    {
        <div>@($"Type:{item.Type}, Value:{item.Value}")</div>
    }
}

<AuthorizeView>
    <NotAuthorized>
        没权限
    </NotAuthorized>
    <Authorized>
        认证过的用户：
        @context.User?.Identity?.Name
    </Authorized>
    <Authorizing>
        授权中...
    </Authorizing>
</AuthorizeView>

@*@inject AuthenticationStateProvider AuthProvider*@

@code{
    [CascadingParameter]Task<AuthenticationState> State{ get; set; }
    AuthenticationState? user;

    async Task Login()
    {
        //user = await AuthProvider.GetAuthenticationStateAsync();
        user = await State;
    }
}